#!/usr/bin/env ts-node
import { PrismaClient, Prisma } from "@prisma/client";
import { faker } from "@faker-js/faker";
console.log("gender:", faker.name.gender());

const prisma = new PrismaClient();
const getFakerUser = () => {
  const localTelephone = faker.phone.phoneNumber("188########");
  return {
    password: faker.internet.password(6),
    telephone: localTelephone,
  };
};

const getProfile = (userId: number, telephone: string) => {
  const localGender = () => {
    switch (faker.name.gender(true)) {
      case "Female":
        return "女";
      case "Male":
        return "男";
    }
  };

  const localName = () => {
    faker.locale = "zh_CN";
    return faker.name.lastName() + faker.name.firstName();
  };

  const englishEmail = () => {
    faker.locale = "en";
    return faker.internet.email();
  };
  return {
    name: localName(),
    telephone: telephone,
    gender: localGender(),
    allowedPages: [],
    email: englishEmail(),
    userId: userId,
  };
};
async function main() {
  const users = await prisma.user.findMany({
    select: {
      id: true,
      telephone: true,
    },
  });
  users.forEach((u) => {
    console.log(getProfile(u.id, u.telephone));
  });
}

main()
  .catch((e) => {
    throw e;
  })
  .finally(async () => {
    await prisma.$disconnect();
  });
